#include "AboutDialog.h"
#include "ui_AboutDialog.h"
#include "MainWindow.h"
#include "Constants.h"
#include <QDebug>
#include <QGraphicsScene>
#include <QPixmap>
#include <QMovie>
#include <QGraphicsItem>
#include <QFont>

QGraphicsScene* scene;
QMovie* movie;

AboutDialog::AboutDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::AboutDialog){
    setFixedSize(340,169);
    setWindowFlags(Qt::Dialog|Qt::WindowCloseButtonHint);
    ui->setupUi(this);
    ui->text->setText(QString(tr("<font style=\"color:black;font-size:17px;font-weight:bold;font-family:'Courier New'\">ApplicationName</font><br /><font style=\"font-size:14px\">Version:%1</font>")).arg(VERSION_NAME));
    ui->text->setFont(QFont("SimHei"));
    scene=NULL;
    //    scene=new QGraphicsScene(0,0,ui->icon->width(),ui->icon->height());
    //    scene->addPixmap(QPixmap(":/Images/Icon").scaled(80,80));
    //    ui->icon->setScene(scene);

    ui->icon->setVisible(false);
    movie=new QMovie(QString(":/Images/About"));
    movie->setPaused(false);
    movie->setScaledSize(QSize(80,80));
    //    movie->setBackgroundColor(Qt::black);
    ui->label->setMovie(movie);
    movie->start();
}

AboutDialog::~AboutDialog(){
    delete scene;
    delete movie;
    delete ui;
}

void AboutDialog::on_btnSure_clicked(){
    this->close();
}

void AboutDialog::closeEvent(QCloseEvent *){
    (dynamic_cast<MainWindow*>(parent()))->deleteWindow(this);
}
